<template>
  <div class="meme-grid-container">
    <div v-if="isLoading && !memes.length" class="loading-container">
      <va-progress-circle indeterminate />
      <p>加载表情包中...</p>
    </div>
    
    <div v-else-if="!memes.length && !isLoading" class="empty-state">
      <va-icon name="sentiment_dissatisfied" size="large" />
      <h3>未找到表情包</h3>
      <p>{{ emptyMessage }}</p>
    </div>
    
    <div v-else class="meme-grid">
      <meme-card
        v-for="meme in memes"
        :key="meme.id"
        :meme="meme"
        class="meme-grid-item"
      />
    </div>
    
    <div v-if="isLoading && memes.length" class="loading-more">
      <va-progress-circle indeterminate />
      <p>加载更多表情包...</p>
    </div>
    
    <div v-if="hasNextPage && !isLoading" class="load-more">
      <va-button @click="$emit('load-more')">
        加载更多
      </va-button>
    </div>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue'
import MemeCard from './MemeCard.vue'

defineProps({
  memes: {
    type: Array,
    default: () => []
  },
  isLoading: {
    type: Boolean,
    default: false
  },
  hasNextPage: {
    type: Boolean,
    default: false
  },
  emptyMessage: {
    type: String,
    default: '尝试更改搜索条件或稍后再查看'
  }
})

defineEmits(['load-more'])
</script>

<style scoped>
.meme-grid-container {
  padding: 1rem 0;
}

.meme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.loading-container,
.empty-state,
.loading-more,
.load-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 0;
  text-align: center;
}

.empty-state {
  color: var(--va-text-secondary);
}

.empty-state h3 {
  margin: 1rem 0 0.5rem;
}

.loading-more {
  padding: 1rem 0;
}

@media (max-width: 992px) {
  .meme-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .meme-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  .meme-grid {
    grid-template-columns: 1fr;
  }
}
</style> 